//
//  MainTabBarCtl.m
//  CoffeeTea
//
//  Created by yuqin on 2018/11/12.
//  Copyright © 2018年 yuqin. All rights reserved.
//

#import "MainTabBarCtl.h"
#import "HomePageViewController.h"
#import "YQQuestionCtl.h"
#import "YQWikipediaCtl.h"
#import "YQInformationCtl.h"
#import "YQMemberCenterCtl.h"

@interface MainTabBarCtl ()

@property (nonatomic, strong) NSArray *imgNormalArr;
@property (nonatomic, strong) NSArray *imgSelectedArr;

@end

@implementation MainTabBarCtl

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置分栏
    [self setupRootCtl];
}

- (void)setupRootCtl
{
    //视频
    HomePageViewController *Vvc = [[HomePageViewController alloc] init];
    UINavigationController *VNav = [[UINavigationController alloc] initWithRootViewController:Vvc];
    
    //知识
    YQQuestionCtl *KVC = [[YQQuestionCtl alloc] init];
    UINavigationController *KNav = [[UINavigationController alloc] initWithRootViewController:KVC];
    
    //社区
    YQWikipediaCtl *CVC = [[YQWikipediaCtl alloc] init];
    UINavigationController *CNav = [[UINavigationController alloc] initWithRootViewController:CVC];
    
    //我的
    YQInformationCtl *PVC = [[YQInformationCtl alloc] init];
    UINavigationController *PNav = [[UINavigationController alloc] initWithRootViewController:PVC];
    
    YQMemberCenterCtl *meVC = [[YQMemberCenterCtl alloc] init];
    UINavigationController *meNav = [[UINavigationController alloc] initWithRootViewController:meVC];
    
    NSArray *NavArr = @[VNav,KNav,CNav,PNav,meNav];
    self.imgNormalArr = [NSArray arrayWithObjects:@"home_video_nor_icon",@"home_knowledge_nor_icon",@"home_social_nor_icon",@"home_mine_nor_icon",@"home_mine_nor_icon", nil];
    self.imgSelectedArr = [NSArray arrayWithObjects:@"home_video_sel_icon",@"home_knowledge_sel_icon",@"home_social_sel_icon",@"home_mine_sel_icon",@"home_mine_nor_icon", nil];
    NSArray *titleArr = @[@"首页",@"问答",@"百科",@"资讯",@"会员中心"];
    
    for (int i = 0; i < NavArr.count; i++) {
        UIViewController *vc = NavArr[i];
        NSString *iconNoralStr = self.imgNormalArr[i];
        NSString *iconSelectedStr = self.imgSelectedArr[i];
        vc.tabBarItem.image = [[UIImage imageNamed:iconNoralStr] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        vc.tabBarItem.selectedImage = [[UIImage imageNamed:iconSelectedStr] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        vc.title = titleArr[i];
        //设置标题样式
        NSDictionary *dict = @{NSForegroundColorAttributeName:HEXCOLOR(0xfefefe),NSFontAttributeName:[UIFont systemFontOfSize:15]};
        [vc.tabBarItem setTitleTextAttributes:dict forState:UIControlStateNormal];
        
        //点击的样式
        NSDictionary *selectedDict = @{NSForegroundColorAttributeName:HEXCOLOR(0x8e582a),NSFontAttributeName:[UIFont systemFontOfSize:15]};
        [vc.tabBarItem setTitleTextAttributes:selectedDict forState:UIControlStateSelected];
    }
    self.viewControllers = NavArr;
    self.selectedIndex = 0;
    
    
}

@end
